package com.qfedu.entity.course12;

public class InsertSort {
    public static void insertSort(int[] arr) {
        for (int i = 1; i < arr.length; i++) {
            int temp = arr[i];
            for (int j = i - 1; j >= 0; j--) {
                if (temp < arr[j]) {
                    arr[j + 1] = arr[j];
                    if (j == 0) {
                        arr[j] = temp;
                    }
                } else {
                    arr[j + 1] = temp;
                    break;
                }
            }
        }
    }
}
